package kr.hkit.powerjava.algorithm;

import java.util.Arrays;

public class Stack {
	private int size;
	private int top;
	private String[] arrItem;
	
	public Stack(int size){
		this.size= size;
		arrItem= new String[size];
		top=-1;
	}
	public void push(String item){
		if(!isFull()){
			arrItem[++top]=item;
		}else{
			System.out.println("Stack Is Full");
		}
	}
	
	public String pop(){
		if (!isEmpty()){
		return arrItem[top--];
		}else{
			return"stack is Empty";
		}
	}
	
	public boolean isFull(){
		return top==size-1;
		}
	public boolean isEmpty(){
		return top==-1;

	}
	@Override
	public String toString() {
		return String.format("%s%n",
				Arrays.toString(arrItem));
	}
	public void prnStack() {
		for ( int i=0; i <= top; i++){
			System.out.printf("[%s]\t",arrItem[i]);
			
		}
		System.out.println();
	}
	
	
	
}
